package com.zufe.test5;

public class GirlFriendTest {
    public static void main(String[] args) {
        GirlFriend gf1 = new GirlFriend("小红", 18, "女", "看书");
        GirlFriend gf2 = new GirlFriend("诗诗", 20, "女", "打游戏");
        GirlFriend gf3 = new GirlFriend("小芳", 22, "女", "逛街");
        GirlFriend gf4 = new GirlFriend("慧慧", 24, "女", "看电影");

        GirlFriend[] girlFriends = new GirlFriend[4];
        girlFriends[0] = gf1;
        girlFriends[1] = gf2;
        girlFriends[2] = gf3;
        girlFriends[3] = gf4;

        int sum = 0;
        for (GirlFriend girlFriend : girlFriends) {
            sum += girlFriend.getAge();
        }
        int avg = sum / girlFriends.length;

        System.out.println("平均年龄：" + avg);
        int count = 0;
        for (GirlFriend girlFriend : girlFriends) {
            if(girlFriend.getAge() < avg){
                count++;
                System.out.println("name:" + girlFriend.getName() + "age:" + girlFriend.getAge() + "gender:" + girlFriend.getGender() + "hobby:" + girlFriend.getHobby());
            }
        }
        System.out.println("小于平均年龄的女朋友个数：" + count);
    }
}
